<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns:ui="http://java.sun.com/jsf/facelets"
                template="/resources/template/template.xhtml"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:f="http://java.sun.com/jsf/core"
                xmlns="http://www.w3.org/1999/xhtml"
                xmlns:p="http://primefaces.org/ui">


    <ui:define name="content" >

        <h:outputStylesheet library="css" name="maincss.css" />
        <h:outputStylesheet library="css" name="printing.css" />

        <h:panelGroup  style="width: 100%;height: 95%;"  >

            <h:form style="width: 100%;height: 95%;" >



                <p:growl />

                <p:panel style="width: 100%;min-height: 600px;" >

                    <p:panelGrid columns="2" style="margin: auto; padding: 1px; border: 1px;" styleClass="alignTop" >


                        <p:panel header="Manage Recieve" >
                            <f:facet name="header" >
                                <h:outputLabel value="Receving Samples and Printing Worksheets" />
                                <p:commandButton ajax="false" value="Refresh" action="/lab/receive" actionListener="#{patientInvestigationController.toPrintWorksheets() }" onclick="onSubmitButton();"  ></p:commandButton>
                                <h:commandButton value="Print Worksheets"  >
                                    <f:ajax execute="@this" listener="#{patientInvestigationController.markSelectedAsReceived}" />
                                    <p:printer  target="pPrintWorksheet" />
                                </h:commandButton>
                            </f:facet>

                            <p:panelGrid columns="2" >

                                <h:panelGroup>

                                    <p:panelGrid columns="5">
                                        <h:outputLabel value="From Date"/>
                                        <p:calendar  pattern="dd MMMM yyyy hh mm ss a"  id="fromDate" value="#{patientInvestigationController.fromDate}"  >
                                            <f:ajax event="dateSelect" execute="toDate fromDate"  render="dtF toDate fromDate"/>
                                        </p:calendar>
                                        <h:outputLabel value="To Date"/>
                                        <p:calendar  pattern="dd MMMM yyyy hh mm ss a"  id="toDate" value="#{patientInvestigationController.toDate}"  >
                                            <f:ajax event="dateSelect" execute="toDate fromDate"  render="dtF toDate fromDate"/>
                                        </p:calendar>
                                    </p:panelGrid>


                                    <p:dataTable id="dtF" value="#{patientInvestigationController.toReceive}" var="smpIx" rowKey="#{smpIx.id}" selection="#{patientInvestigationController.selectedToReceive}" >
                                        <p:ajax event="rowSelectCheckbox" 
                                                update=":#{p:component('pPrintWorksheet')}" process="colSelect dtF"      />  
                                        <p:ajax event="rowUnselectCheckbox" 
                                                update=":#{p:component('pPrintWorksheet')}" process="colSelect dtF"      />  
                                        <p:ajax event="toggleSelect" 
                                                update=":#{p:component('pPrintWorksheet')}" process="colSelect dtF"      />  
                                        <p:column id="colSelect"  selectionMode="multiple" >
                                        </p:column>
                                        <p:column headerText="Patient"  styleClass="alignTop" >
                                            <h:outputLabel value="#{smpIx.billItem.bill.patient.person.nameWithTitle}" >
                                            </h:outputLabel>
                                            &nbsp;&nbsp;&nbsp;&nbsp;
                                            <br/>
                                            <h:outputLabel value="#{smpIx.billItem.bill.patient.age}" >
                                            </h:outputLabel>
                                            <br/>
                                            <h:outputLabel value="#{smpIx.billItem.bill.patient.person.sex}" >
                                            </h:outputLabel>
                                            <br/>
                                            <h:outputLabel value="#{smpIx.billItem.bill.patient.person.phone}" >
                                            </h:outputLabel>
                                            <br/>
                                            <h:outputLabel value="#{smpIx.billItem.bill.insId}" >
                                            </h:outputLabel>
                                        </p:column>

                                        <p:column headerText="Investigation"  styleClass="alignTop" >
                                            <h:outputLabel value="#{smpIx.billItem.item.name}" >
                                            </h:outputLabel>
                                            <br/>
                                            <h:outputLabel value="Billed at " />
                                            <h:outputLabel value="#{smpIx.billItem.bill.createdAt}" >
                                                <f:convertDateTime pattern="dd/MMM/yyyy - hh:mm:ss a"/>
                                            </h:outputLabel>
                                            <br/>
                                            <h:outputLabel value="Sampled at " />
                                            <h:outputLabel id="lblSample" rendered="#{smpIx.collected}" value="#{smpIx.sampledAt}" >
                                                <f:convertDateTime pattern="dd/MMM/yyyy - hh:mm:ss a"/>
                                            </h:outputLabel>
                                            <br/>
                                            <h:outputLabel value="Received at " />
                                            <h:outputLabel rendered="#{smpIx.received}" value="#{smpIx.receivedAt}" >
                                                <f:convertDateTime pattern="dd/MMM/yyyy - hh:mm:ss a"/>
                                            </h:outputLabel>
                                            <br/>
                                            <h:panelGroup rendered="#{smpIx.billItem.bill.cancelled}" >
                                                <h:outputLabel style="color: red;" value="Cancelled at " />
                                                <h:outputLabel style="color: red;" rendered="#{smpIx.billItem.bill.cancelled}" value="#{smpIx.billItem.bill.cancelledBill.createdAt}" >
                                                    <f:convertDateTime pattern="dd/MMM/yyyy - hh:mm:ss a"/>
                                                </h:outputLabel>
                                            </h:panelGroup>
                                            <h:panelGroup rendered="#{smpIx.billItem.refunded}" >
                                                <h:outputLabel style="color: red;" value="Refunded at " />
                                                <h:outputLabel style="color: red;" rendered="#{smpIx.billItem.refunded}" value="#{smpIx.billItem.referanceBillItem.bill.createdAt}" >
                                                    <f:convertDateTime pattern="dd/MMM/yyyy - hh:mm:ss a"/>
                                                </h:outputLabel>
                                            </h:panelGroup>
                                            <br/>
                                        </p:column>

                                    </p:dataTable>

                                </h:panelGroup>
                                <h:panelGroup >

                                    <h:panelGroup id="pWorksheet">
                                        <p:panel id="pPrintWorksheet"  style="margin: auto; border: 0px; padding: 0px; font-size:110%" >

                                            <div >
                                                <div>
                                                    <ui:repeat value="#{patientInvestigationController.selectedToReceive}" var="pip" >

                                                        <div></div>

                                                        <div class="fiveinchbill" >

                                                            <h:panelGrid columns="5" style="padding-top: 50px; padding-left:  20px;" >

                                                                <h:outputLabel  value="Name : " />
                                                                <h:outputLabel styleClass="worksheetfont" value="#{pip.patient.person.nameWithTitle}"  style="font-size: 11px!important;" ></h:outputLabel>
                                                                <h:outputLabel  value="" />
                                                                <h:outputLabel  style="font-size: 11px!important;" value="Sex : " />
                                                                <h:outputLabel value="#{pip.patient.person.sex}"  style="font-size: 11px!important;"  ></h:outputLabel>


                                                                <h:outputLabel  value="Age : "  style="font-size: 11px!important;" />
                                                                <h:outputLabel  value="#{pip.patient.age }"  style="font-size: 11px!important;" ></h:outputLabel>
                                                                <h:outputLabel  value="" />
                                                                <h:outputLabel value="Doc : "  style="font-size: 11px!important;" />
                                                                <h:outputLabel value="#{pip.billItem.bill.referredBy.person.nameWithTitle}"  style="font-size: 11px!important;" ></h:outputLabel>

                                                                <h:outputLabel value="Investigation : "  style="font-size: 11px!important;" />
                                                                <h:outputLabel  style="font-size: 11px!important;"  styleClass="worksheetfont" value="#{pip.investigation.printName}" ></h:outputLabel>
                                                                <h:outputLabel value="Id : "  style="font-size: 11px!important;" />
                                                                <h:outputLabel value="#{pip.billItem.bill.insId}" style="font-size: 11px!important;"  ></h:outputLabel>

                                                            </h:panelGrid>

                                                            <h:panelGrid rendered="#{pip.investigation.reportType ne 'Microbiology'}" >
                                                                <ui:repeat value="#{pip.investigation.reportItems}" var="myix" >
                                                                    <h:panelGroup rendered="#{myix.retired==false and myix.ixItemType eq 'Value' }"  >                                      
                                                                        <h:outputLabel  rendered="#{myix.retired==false and myix.ixItemType eq 'Value' }" styleClass="worksheetval" value="#{myix.name}"  style="font-size: 11px!important;"  ></h:outputLabel>
                                                                        <h:outputLabel styleClass="worksheetval" value="_____________"  rendered="#{myix.retired==false and myix.ixItemType eq 'Value' }"  style="font-size: 11px!important;" ></h:outputLabel>
                                                                        <br/>
                                                                    </h:panelGroup>

                                                                </ui:repeat>

                                                            </h:panelGrid>

                                                            <h:panelGroup rendered="#{pip.investigation.reportType eq 'Microbiology'}"  style="width: 100%;" >
                                                                <p:panelGrid columns="2"  >

                                                                    <h:outputLabel value="Macroscopy"   style="font-size: 11px!important;">
                                                                    </h:outputLabel>
                                                                    <h:outputLabel value="................................................................................................"   style="font-size: 11px!important;">
                                                                    </h:outputLabel>

                                                                    <h:outputLabel value="Microscopy"   style="font-size: 11px!important;">
                                                                    </h:outputLabel>
                                                                    <h:outputLabel value="........................................................................"   style="font-size: 11px!important;">
                                                                    </h:outputLabel>

                                                                    <h:outputLabel value="Colony Count"   style="font-size: 11px!important;">
                                                                    </h:outputLabel>
                                                                    <h:outputLabel value="........................................................................"   style="font-size: 11px!important;">
                                                                    </h:outputLabel>

                                                                    <h:outputLabel value="Comments"   style="font-size: 11px!important;">
                                                                    </h:outputLabel>
                                                                    <h:outputLabel value="........................................................................"   style="font-size: 11px!important;">
                                                                    </h:outputLabel>
                                                                </p:panelGrid>

                                                                <p:dataGrid style="padding: 1px!important;margin: 1px!important;" columns="4" value="#{antibioticController.items}" var="ab" >
                                                                        <h:outputLabel value="#{ab.code}"   style="font-size: 11px!important;"></h:outputLabel>
                                                                        <h:outputLabel value="&nbsp;&nbsp;&nbsp;&nbsp;"   style="font-size: 11px!important;"></h:outputLabel>
                                                                        <h:outputLabel value="....."   style="font-size: 11px!important;"></h:outputLabel>
                                                                        <h:outputLabel value="&nbsp;&nbsp;&nbsp;&nbsp;"   style="font-size: 11px!important;"></h:outputLabel>
                                                                </p:dataGrid>

                                                            </h:panelGroup>

                                                        </div>

                                                    </ui:repeat>
                                                </div>
                                            </div>
                                        </p:panel>
                                    </h:panelGroup>


                                </h:panelGroup>
                            </p:panelGrid>
                        </p:panel>


                    </p:panelGrid>

                </p:panel>

            </h:form>
        </h:panelGroup>
    </ui:define>

</ui:composition>
